package com.example.a22310.myapplication.ViewModel.Attention;


import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;

import com.example.a22310.myapplication.Adapter.MvvmAdapter;
import com.example.a22310.myapplication.Beans.Attention;
import com.example.a22310.myapplication.Listener.ActivityLisenter;
import com.example.a22310.myapplication.Model.AttentionModel;
import com.example.a22310.myapplication.R;

import java.util.List;

public class AtttentionViewModel implements ActivityLisenter<Attention> {

    private ActivityAttentionBinding binding;
    private AppCompatActivity activity;
    private int userid;
    private int flag;
    public AtttentionViewModel(AppCompatActivity activity, ActivityAttentionBinding binding,int userid,int flag){
        this.activity = activity;
        this.binding = binding;
        this.userid = userid;
        this.flag =flag;
        binding.setDetail(this);
        AttentionModel attentionModel=new AttentionModel();
        attentionModel.attentionlist(AtttentionViewModel.this,userid,flag);

    }

    public void back(View view){
        activity.onBackPressed();
    }

    @Override
    public void onSuccess(Attention attention) {
        if(attention.getCode()!=404) {
            List<Attention.AttentiondataBean> attentionlistBeen = attention.getAttentiondata();
            binding.recyclerViewAttention.setLayoutManager(
                    new LinearLayoutManager(activity));
            MvvmAdapter adapter = new MvvmAdapter(activity, R.layout.cardview_attention,
                    attentionlistBeen, BR.attention);
            binding.recyclerViewAttention.setAdapter(adapter);
        }



    }

    @Override
    public void onFailure() {
    }




}
